#pragma once

#include <QWidget>
#include <QQueue>
#include "util/serverhelper.h"
#include "util/usermanager.h"
#include "poco/word.h"

namespace Ui {
class WordPage;
}

namespace WordMemory
{
    class WordPage : public QWidget
    {
        Q_OBJECT

    public:
        explicit WordPage(QWidget *parent = nullptr);
        ~WordPage();

        void displayWord(const QString &word);

    private slots:
        void on_viewAllExamplesButton_clicked();
        void on_viewAllMnemonicsButton_clicked();
        void on_forgotButton_clicked();
        void on_vagueButton_clicked();
        void on_knownButton_clicked();
        void on_favoriteButton_clicked();

        void on_nextWord();

    private:
        void setupConnections();
        void setupStyles();
        void updateWordDisplay(const Word &word);
        void updateFavoriteButtonState(bool isFavorite);

        void loadDefaultVocabularyWords();
        void displayCurrentWord();

     private:
        Ui::WordPage *ui;
        ServerHelper *serverhelper;

        Word currentWord;
        Vocabulary defaultVocabulary;

        QQueue<Word> defaultWordQueue; // 默认单词队列
        QQueue<Word> vagueWordQueue;   // 模糊单词队列
        QQueue<Word> forgotWordQueue;  // 忘记单词队列

        enum class CurrentQueue { Default, Vague, Forgot, None };
        CurrentQueue currentQueueType = CurrentQueue::None;
    };
}
